package com.yuch.service.impl.activemq;

import com.yuch.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class MessageServiceActivemqImpl implements MessageService {
//    List<String> list=new ArrayList<String>();
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;


    @Override
    public String sendMessage(String id) {
        System.out.println("消息添加到队列:"+id);
//        list.add(id);
        jmsMessagingTemplate.convertAndSend("yuchuang",id);
        return id;
    }

    @Override
    public String doMessage() {
//        String id =  list.remove(0);
//        String id = jmsMessagingTemplate.receiveAndConvert("yuchaung",String.class);
//        System.out.println("消息发送成功:"+id);
        return "id";
    }
}
